package com.attendance.www.hr.timer;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.attendance.www.hr.service.IAttendanceReportService;

@Service
public class AttendanceReportTimer {
	
	@Resource
	private IAttendanceReportService attendanceReportService;
	
	/**
	 * 每日生成考勤报表数据
	 */
	public void generateAttendanceReport() {
		//获取昨天考勤信息
		Calendar cal=Calendar.getInstance();
		cal.add(Calendar.DATE,-1);
		Date startDate=cal.getTime();
		Date endDate=cal.getTime();
		//规定返回日期格式
/*		SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
		Calendar calendar=Calendar.getInstance();
		//设置为第一天
		calendar.set(Calendar.DAY_OF_MONTH, 1);
		String day_first=sf.format(calendar.getTime());
		//打印本月第一天
		System.out.println(day_first);*/
		attendanceReportService.saveAttendanceReport(startDate, endDate);
	}
}
